package manager.connection.type;

import io.netty.channel.ChannelHandlerContext;

public class ConnectionInfo {
	private ChannelHandlerContext ctx = null;
	private int machineId = -1;
	private String loginedOpenid = "";
	private String privateIp = "";//机器内网ip
	private int privatePort = 0;
	private String publicIp = "";//机器外网ip
	private int publicPort = 0;
	private long pingTime=0;

	public long getPingTime() {
		return pingTime;
	}
	public void setPingTime(long pingTime) {
		this.pingTime = pingTime;
	}
	public String getPrivateIp() {
		return privateIp;
	}
	public void setPrivateIp(String privateIp) {
		this.privateIp = privateIp;
	}
	public int getPrivatePort() {
		return privatePort;
	}
	public void setPrivatePort(int privatePort) {
		this.privatePort = privatePort;
	}
	public String getPublicIp() {
		return publicIp;
	}
	public void setPublicIp(String publicIp) {
		this.publicIp = publicIp;
	}
	public int getPublicPort() {
		return publicPort;
	}
	public void setPublicPort(int publicPort) {
		this.publicPort = publicPort;
	}
	public int getMachineId() {
		return machineId;
	}

	public void setMachineId(int machineId) {
		this.machineId = machineId;
	}
	public ChannelHandlerContext getCtx() {
		return ctx;
	}
	
	public void setCtx(ChannelHandlerContext ctx) {
		this.ctx = ctx;
	}
	
	public String getLoginedOpenid() {
		synchronized(loginedOpenid){
			return loginedOpenid;
		}
	}
	
	public void setLoginedOpenid(String loginedOpenid) {
		synchronized(this.loginedOpenid){
			this.loginedOpenid = loginedOpenid;
		}
	}
	
	
	@Override public boolean equals(Object obj){
		if(obj == this){
			return true;
		}
		else if(obj instanceof ConnectionInfo){
			if (((ConnectionInfo) obj).getCtx().equals(this.ctx))
				return true;
		}
		return false;	
	}
}
